package org.example.chapter3;

import javax.sound.sampled.SourceDataLine;
import java.util.Scanner;

public class LotteryUsingString {
    public static void main(String[] args) {
        String lottery=""+(int)(Math.random()*10)+(int)(Math.random()*10);
        Scanner sc=new Scanner(System.in);
        System.out.println("enter lottery (two digits): ");
       String guess= sc.nextLine();

        char lotteryChar1=lottery.charAt(0);
        char lotteryChar2=lottery.charAt(1);

        char guessChar1=guess.charAt(0);
        char guessChar2=guess.charAt(1);


        System.out.println("The lottery is: "+lottery);

        if(guess.equals(lottery)){
            System.out.println("Exact match you win $10000");
        }else if(guessChar1==lotteryChar2&&guessChar2 ==lotteryChar1){
            System.out.println("Match all digits: you win $3000");
        } else if (guessChar1 == lotteryChar1 || guessChar1 == guessChar2
        || guessChar2 == lotteryChar2 || guessChar2 == lotteryChar1) {
            System.out.println("Match one digit: you win $1000");
        }else {
            System.out.println("Sorry,no match");
        }

    }
}
